#ifndef _DevicesADC_H_
#define _DevicesADC_H_



/* DC12V输出电压 */
#define ADC_SAMPLE_DC12V_OUT_VOLTAGE ADC_CHANNEL_11
/* DC12V电感电流 */
#define ADC_SAMPLE_DC12V_INDUCTIVE_CURRENT ADC_CHANNEL_12
/* DC24V输出电压 */
#define ADC_SAMPLE_DC24V_OUT_VOLTAGE ADC_CHANNEL_10
/* DC24V电感电流 */
#define ADC_SAMPLE_DC24V_INDUCTIVE_CURRENT ADC_CHANNEL_0


/* 电池电压 */
#define ADC_SAMPLE_BATTERY_VOLTAGE ADC_CHANNEL_13
/* 环境温度 */
#define ADC_SAMPLE_AMBIENT_TEMPERATURE ADC_CHANNEL_5
/* DC温度 */
#define ADC_SAMPLE_DC12V_TEMPERATURE ADC_CHANNEL_7



/* DC USBA 12W A 电压 */
#define ADC_SAMPLE_DC_USBA_Low_A_VOLTAGE ADC_CHANNEL_1
/* DC USBA 12W B 电压 */
#define ADC_SAMPLE_DC_USBA_Low_B_VOLTAGE ADC_CHANNEL_1
/* DC USBA 18W 电压 */
#define ADC_SAMPLE_DC_USBA_High_A_VOLTAGE ADC_CHANNEL_2
/* DC USBC 30W A 电压 */
#define ADC_SAMPLE_DC_USBC_Low_A_VOLTAGE ADC_CHANNEL_2
/* DC USBC 100W 电压 */
#define ADC_SAMPLE_DC_USBC_High_A_VOLTAGE ADC_CHANNEL_3
/* DC USBC 30W B 电压 */
#define ADC_SAMPLE_DC_USBC_Low_B_VOLTAGE ADC_CHANNEL_3


/* DC USBA 12W B 电流 */
#define ADC_SAMPLE_DC_USBA_Low_B_CURRENT ADC_CHANNEL_4
/* DC USBA 12W A 电流 */
#define ADC_SAMPLE_DC_USBA_Low_A_CURRENT ADC_CHANNEL_4
/* DC USBA 18W 电流 */
#define ADC_SAMPLE_DC_USBA_High_A_CURRENT ADC_CHANNEL_14
/* DC USBC 30W A 电流 */
#define ADC_SAMPLE_DC_USBC_Low_A_CURRENT ADC_CHANNEL_14
/* DC USBC 30W B 电流 */
#define ADC_SAMPLE_DC_USBC_Low_B_CURRENT ADC_CHANNEL_15
/* DC USBC 100W 电流 */
#define ADC_SAMPLE_DC_USBC_High_A_CURRENT ADC_CHANNEL_15


/* DC 12V 4A B 电流 */
#define ADC_SAMPLE_DC_12V_4AB_CURRENT ADC_CHANNEL_8
/* DC 12V 4A A 电流 */
#define ADC_SAMPLE_DC_12V_4AA_CURRENT ADC_CHANNEL_8
/* DC 24V PSC */
#define ADC_SAMPLE_DC_24V_VOLTAGE ADC_CHANNEL_9
/* DC 12V 10A A 电流 */
#define ADC_SAMPLE_DC_12V_10A_CURRENT ADC_CHANNEL_9




typedef enum {
/* 电感电流 */
ADC_DMA_SCAN_DC12V_OUT_CURRENT = 0,
/* 输出电压 */
ADC_DMA_SCAN_DC12V_OUT_VOLTAGE,
/* 电感电流 */
ADC_DMA_SCAN_DC24V_OUT_CURRENT,
/* 输出电压 */
ADC_DMA_SCAN_DC24V_OUT_VOLTAGE,

/* 最大的通道值 */
ADC_DMA_SCAN_MAX,
} AdcDmaScanChannelEnum;

typedef enum {
/* 电池电压 */
ADC_SOFT_SCAN_BATTERY_VOLTAGE = 0,
/* 环境温度 */
ADC_SOFT_SCAN_AMBIENT_TEMPERATURE,
/* DC温度 */
ADC_SOFT_SCAN_DC12V_TEMPERATURE,

/* DC USBA 12W A 电压 */
ADC_SOFT_DC_USBA_Low_A_VOLTAGE,
/* DC USBA 12W B 电压 */
ADC_SOFT_DC_USBA_Low_B_VOLTAGE,
/* DC USBA 18W 电压 */
ADC_SOFT_DC_USBA_High_A_VOLTAGE,
/* DC USBA 30W A 电压 */
ADC_SOFT_DC_USBC_Low_A_VOLTAGE,
/* DC USBA 30W B 电压 */
ADC_SOFT_DC_USBC_Low_B_VOLTAGE,
/* DC USBA 100W 电压 */
ADC_SOFT_DC_USBC_High_A_VOLTAGE,

/* DC USBA 12W A 电流 */
ADC_SOFT_DC_USBA_Low_A_CURRENT,
/* DC USBA 12W B 电流 */
ADC_SOFT_DC_USBA_Low_B_CURRENT,
/* DC USBA 18W 电流 */
ADC_SOFT_DC_USBA_High_A_CURRENT,
/* DC USBC 30W B 电流 */
ADC_SOFT_DC_USBC_Low_A_CURRENT,
/* DC USBC 30W A 电流 */
ADC_SOFT_DC_USBC_Low_B_CURRENT,
/* DC USBC 100W 电流 */
ADC_SOFT_DC_USBC_High_A_CURRENT,

/* DC 12V 4A A 电流 */
ADC_SOFT_DC_12V_4AA_CURRENT,
/* DC 12V 4A B 电流 */
ADC_SOFT_DC_12V_4AB_CURRENT,
/* DC 12V 10A A 电流 */
ADC_SOFT_DC_12V_10A_CURRENT,
/* DC 24V PSC */
ADC_SOFT_DC_24V_VOLTAGE,

/* 最大的通道值 */
ADC_SOFT_MAX,
} AdcSoftScanChannelEnum;



/* 采样扫描通道数量 */
#define ADC0_SAMPLING_CHANNEL 4
#define ADC1_SAMPLING_CHANNEL 1
#define ADC2_SAMPLING_CHANNEL 1
/* 每通道采样次数 */
#define ADC0_SAMPLING_NUMBER 1
#define ADC1_SAMPLING_NUMBER 4
#define ADC2_SAMPLING_NUMBER 1
/* 采样时间 */
#define ADC0_SAMPLE_TIME ADC_SAMPLETIME_7POINT5
#define ADC1_SAMPLE_TIME ADC_SAMPLETIME_28POINT5
#define ADC2_SAMPLE_TIME ADC_SAMPLETIME_28POINT5



/* 采样通道，板上硬件二选一控制IO */
#define AD_CHANNEL_CHOICE_GPIO_Port GPIOD
#define AD_CHANNEL_CHOICE_Pin GPIO_PIN_3






void vADCInit(void);
void vADCWatchdogInit(void);
void vADCWatchdogSwitchSet(int8_t cState);

float fADCGetDMAValue(uint8_t ucChannel);
float fADCGetSoftScanValue(uint8_t ucChannel);
float fADCGetChannelValue(uint32_t adc_periph, uint8_t channel, uint32_t uiCnt);

int8_t cADCSoftScanUpdate(void);

#endif 
